HybridMail Technical - Comparators
Updated: 19-12-2022 10:02

Comparators

A comparator is an XML element for determining the difference between two identifiers.

Schema

<compareIdentifiers [identifier="identifier-to-be-compared"] | [scan="X,Y,W,H"]
	comparator="identifier-to-compare-against"
	type="type-of-comparison" >{identifier},{comparator}</compareIdentifiers>

N.B.

  • The comparator is always compared with (‘subtracted from’) the identifier.
  • Neither the comparator nor the identifier is changed as a result of the comparison.
  • The result of the comparison is placed in an identifier with the reserved name compResult
  • compResult can be used in subsequent <if> elements
  • compResult is overwritten after each new <compareIdentifiers>
<compareIdentifier identifier="identifier-name" | scan="X,Y,W,H" />

Specifies the name of an identifier to compare, or the scan area containing text to compare.

<compareIdentifier comparator="identifier-name" />

Specifies the name of a second identifier to be compared against the first.

<compareIdentifier type="type-of-comparison" />

Specifies the type of comparison to perform. The supported types are: 'numberCompare', 'numberDifference', 'daysDifference', workingDaysDifference.

numberCompare

The identifier and comparator must both represent valid decimal numbers. One of the following values will be set in the compResult identifier.

equal         the identifier and comparator are equal
greaterThan   the identifier is numerically greater than the comparator
lessThan      the identifier is numerically less than the comparator
invalidNumber either the identifier or the comparator was not a valid number

numberDifference

The identifier and comparator must both represent valid decimal numbers. One of the following values will be set in the compResult identifier.

nn            where 'nn' is the difference between the identifier and comparator
invalidNumber either the identifier or the comparator was not a valid number

daysDifference

The identifier and comparator must both represent valid dates. One of the following values will be set in the compResult identifier.

nn            where 'nn' is the number of days between the identifier and comparator
invalidDate   either the identifier or the comparator was not a valid date

workingDaysDifference

The identifier and comparator must both represent valid dates. One of the following values will be set in the compResult identifier.

nn            where 'nn' is the number of working days between the identifier and comparator
invalidDate   either the identifier or the comparator was not a valid date

Examples

Check if the recipient is over 18 years of age.

<setIdentifier name="dateOfLetter" scan="131,29,76,39" dateTime="true" />
<setIdentifier name="dateOfBirth"  scan="22,89,173,87" dateTime="true" />
<setIdentifier name="eighteenYears">6570</setIdentifier>    <!--  6570 = 18*365 -->

	<!-- ORIGINAL SYNTAX -->
<compareIdentifiers  identifier="dateOfLetter" comparator="dateOfBirth" type="daysDifference" />
<compareIdentifiers  identifier="compResult" comparator="eighteenYears" type="numberCompare" />
	<!-- ALTERNATIVE SYNTAX -->
<compareIdentifiers type="daysDifference" >{dateOfLetter},{dateOfBirth}</compareIdentifiers>
<compareIdentifiers type="numberCompare" >{compResult},{eighteenYears}</compareIdentifiers>
				
<if identifier="compResult" contains="greaterThan">  
	<!-- recipient is over 18 -->
</if>

Send a letter first class if the appointment date is 10 working days or fewer ahead.

<setIdentifier name="dateOfLetter" scan="131,29,76,39" dateTime="true" />
<setIdentifier name="dateOfAppt"  scan="22,89,173,87" dateTime="true" />
<setIdentifier name="tenDays">10</setIdentifier> 

	<!-- ORIGINAL SYNTAX -->
<compareIdentifiers identifier="dateOfAppt" comparator="dateOfLetter"  type="workingDaysDifference" />
<compareIdentifiers identifier="compResult" comparator="tenDays" type="numberCompare" />
	<!-- ALTERNATIVE SYNTAX -->
<compareIdentifiers type="workingDaysDifference" >{dateOfAppt},{dateOfLetter}</compareIdentifiers>
<compareIdentifiers type="numberCompare" >{compResult},10</compareIdentifiers>
				
<if identifier="compResult" containsOneOf="equal,lessThan">
		<!-- send letter first class -->
</if>